package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends Activity { private EditText edit; private TextView txt1,txt2; private Button mButton01; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txt1 = (TextView)findViewById(R.id.myTextView01); txt2 = (TextView)findViewById(R.id.myTextView02); edit = (EditText)findViewById(R.id.myEditText); mButton01 = (Button)findViewById(R.id.myButton); mButton01.setOnClickListener(new mClick()); } class mClick implements View.OnClickListener { public void onClick(View v) { String passwd; passwd=edit.getText().toString(); if (passwd.equals(“abc123”)) txt2.setText(“欢迎进入!”); else txt2.setText(“非法用户,请立即离开!”); } } }